#ifndef GAMEAUDIOMANAGER_H
#define GAMEAUDIOMANAGER_H

#include <string>
#include <unordered_map>
#include <memory>
#include "../Resourse_manager/AudioAsset.h"

namespace GameEngine {

class GameAudioManager {
public:
    static GameAudioManager& getInstance();
    
    // 音频资源管理
    bool loadAudio(const std::string& id, const std::string& filePath);
    void unloadAudio(const std::string& id);
    void unloadAllAudio();
    
    // 背景音乐控制
    bool playBackgroundMusic(const std::string& id, bool loop = true);
    void stopBackgroundMusic();
    void pauseBackgroundMusic();
    void resumeBackgroundMusic();
    void setBackgroundMusicVolume(float volume);
    
    // 音效控制
    bool playSoundEffect(const std::string& id);
    void setSoundEffectVolume(float volume);
    
    // 全局音频控制
    void setMasterVolume(float volume);
    void muteAll(bool mute);
    
    // 淡入淡出效果
    void fadeInBackgroundMusic(float duration);
    void fadeOutBackgroundMusic(float duration);
    
    // 场景切换音频管理
    void switchBackgroundMusic(const std::string& newMusicId, float fadeOutDuration = 1.0f, float fadeInDuration = 1.0f);
    
private:
    GameAudioManager() = default;
    ~GameAudioManager();
    
    GameAudioManager(const GameAudioManager&) = delete;
    GameAudioManager& operator=(const GameAudioManager&) = delete;
    
    std::unordered_map<std::string, std::shared_ptr<AudioAsset>> m_audioAssets;
    std::string m_currentBackgroundMusic;
    float m_backgroundMusicVolume = 80.0f;
    float m_soundEffectVolume = 100.0f;
    float m_masterVolume = 100.0f;
    bool m_isMuted = false;
};

} // namespace GameEngine

#endif // GAMEAUDIOMANAGER_H
